package org.jeecg.modules.yw.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.jeecg.modules.yw.entity.WarrantyCard;
import org.jeecg.modules.yw.service.WarrantyCardService;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Api(tags = "质保卡管理")
@RequestMapping("/app/warrantyCard")
public class WarrantyCardController {

    @Resource
    private WarrantyCardService warrantyCardService;
    @RequestMapping("/page")
    public  org.jeecg.common.api.vo.Result page(Page<WarrantyCard> page,
                                                @RequestParam(name = "name", required = false) String name,
                                                @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
                                                @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize ) {
        page.setCurrent(pageNo);
        page.setSize(pageSize);
        QueryWrapper<WarrantyCard> queryWrapper = new QueryWrapper<>();
        if(name != null) {
            queryWrapper.like("name", name);
        }
        queryWrapper.orderByDesc("createtime");
        IPage<WarrantyCard> result = warrantyCardService.page(page, queryWrapper);
        return  org.jeecg.common.api.vo.Result.ok(result);
    }
}
